﻿using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NLog;
using VideoReDo;
using ManyConsole;

namespace Processor
{
   class Program
   {
      static Logger Log = LogManager.GetCurrentClassLogger();

      static void Main(string[] args)
      {
         // locate any commands in the assembly (or use an IoC container, or whatever source)
         var commands = GetCommands();

         // optionally, include ConsoleModeCommand if you want to allow the user to run
         // commands from the console.
         ConsoleModeCommand consoleRunner = new ConsoleModeCommand(GetCommands);
         commands = commands.Concat(new[] { consoleRunner });

         Log.Debug("Processor starting...");
         Log.Debug("  Current Directory: {0}", Environment.CurrentDirectory);
         Log.Debug("  Command-Line: {0}", Environment.CommandLine);
         Log.Debug("  Username: {0}", Environment.UserName);

         Console.WriteLine("Processor v0.0.1");
         Console.WriteLine("================\n");

         // run the command for the console input
         ConsoleCommandDispatcher.DispatchCommand(commands, args, Console.Out);
      }

      static IEnumerable<ConsoleCommand> GetCommands()
      {
         return ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(Program));
      }
   }
}
